#!/bin/bash

[ -z "$1" ] && echo "1st argument must be a font string in a format that urxvt recognizes" && exit 1

tmpfile="${TMPDIR:-/tmp}/${0##*/}$RANDOM"
trap 'rm "$tmpfile"' EXIT

# disable as many options as possible.
urxvtopts=( -iconic -name donotloadanyresources -geometry 1x1 +rv +ss +j -fade 0 +is +ls +vb +sb +si -sl 0 -pe '' +ssc +hold -lsp 0 -letsp 0 -bc -uc -b 0 -w 0 -bl -override-redirect )

unset HOME; urxvt -fn "$1" -geometry 1x1 "${urxvtopts[@]}" \
-e sh -c "xdotool getwindowgeometry --shell \$WINDOWID > \"$tmpfile\""

sed '/WIDTH\|HEIGHT/!d' "$tmpfile"
